package com.example.demo.control;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoControl {

    @RequestMapping(value = "/demo1")
    public String demo1() {
        return "hello world 333";
    }

    @RequestMapping(value = "/demo2")
    public UserBean demo2() {
        UserBean userBean = new UserBean();
        userBean.setName("22");
        userBean.setPd("22");
        return userBean;
    }

    @RequestMapping(value = "/demo3")
    public UserBean demo3() {
        UserBean userBean = new UserBean();
        userBean.setName("33");
        userBean.setPd("33");
        return userBean;
    }

    /**
     * {@link com.example.demo.config.MyExceptionHandler}
     *
     * @return
     */
    @RequestMapping(value = "/demo4")
    public String demo4() {
        if (true) {
            throw new RuntimeException("demo4 RuntimeException");
        }
        return "aaa";
    }

    @RequestMapping(value = "/fail")
    public String fail_() {
        return "fail";
    }

    @RequestMapping(value = "/*")
    public String noPage_() {
        return "noPage 404";
    }
}
